<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册页面</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }
        .container {
            background-color: #fff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            width: 300px;
        }
        h1 {
            text-align: center;
            color: #333;
        }
        form {
            display: flex;
            flex-direction: column;
        }
        form input[type="text"],
        form input[type="password"] {
            padding: 10px;
            margin: 10px 0;
            border: 1px solid #ccc;
            border-radius: 4px;
        }
        form input[type="submit"] {
            background-color: #5cb85c;
            color: white;
            border: none;
            border-radius: 4px;
            padding: 10px;
            cursor: pointer;
        }
        form input[type="submit"]:hover {
            background-color: #4cae3c;
        }
        a {
            display: block;
            text-align: center;
            margin-top: 20px;
            color: #5cb85c;
            text-decoration: none;
        }
        a:hover {
            text-decoration: underline;
        }
    </style>
    <script>
        // 显示消息的函数
        function showMessage(message) {
            if (message) {
                alert(message);
            }
        }
    </script>
</head>
<body>
<div class="container">
    <h1>注册</h1>
    <form action="/register" method="post">
        用户名: <input type="text" name="user"><br>
        密码: <input type="password" name="pass"><br>
        <input type="submit" value="注册">
    </form>
    <a href="/login">已有账号？去登录</a>
</div>
<script>
    // 检查 URL 中的消息参数
    const urlParams = new URLSearchParams(window.location.search);
    const message = urlParams.get('message');
    let alertMessage;

    // 根据不同的消息显示不同的提示
    switch (message) {
        case 'exists':
            alertMessage = '用户已存在，请选择其他用户名';
            break;
        case 'success':
            alertMessage = '注册成功，请登录';
            break;
        case 'error':
            alertMessage = '发生错误，请稍后重试';
            break;
        default:
            alertMessage = null;
    }

    showMessage(alertMessage);
</script>
</body>
</html>